<template>
  <zm-view ref="view">
    <zm-list ref="list" :options="options" @query="handleQuery">
      <view v-for="(item, index) in list" :key="index" class="radius-16 mx-24 mt-20">
        <film-card-horizontal :data="item" @collect="$refs.list.refresh()"></film-card-horizontal>
      </view>
    </zm-list>
    <!-- 电影预告播放组件 -->
    <film-trailer-popup></film-trailer-popup>
  </zm-view>
</template>

<script>
import page from "@/mixins/page"
import hook from "@/mixins/hook"
import { useImage } from "@/utils/hook"
export default {
  mixins: [page, hook],
  data() {
    return {
      list: [],
      options: {
        emptyText: "暂无收藏的想看电影",
        emptyImage: useImage("/zuimei-film-oss/1.0.0/empty/zwsc-empty.png")
      }
    }
  },
  methods: {
    async handleQuery({ type, page, pageSize, fail, success }) {
      try {
        const res = await this.$api.film.getCollectionList({ page, pageSize })
        this.list = type == "load" ? [...this.list, ...res.list] : res.list
        this.list.forEach((item) => (item.isCollect = 1))
        success({ list: res.list, total: res.count })
      } catch (e) {
        fail()
      }
    }
  }
}
</script>

<style lang="scss" scoped></style>
